<template>
  <sweet-modal ref="prints" class="dialog" :sweetModalMaxWidth="pageWidth">
            <h3>{{title}}</h3>
            <iframe :src="printUrl" style="width:1000px; height:500px;margin-top:20px;"></iframe>
        </sweet-modal>
</template>

<style  rel="stylesheet/scss" lang="scss" scoped>

</style>
<script>
const INFO="详情"
const REPRINT="补打火化证明";
const REPRINTS="补打联办单";
import apiBase from "@/api/apiBase.js";
import sweetModal from "@/components/sweetModal";

  export default {
      data(){
          return{
              title:null,
           printUrl:null,
           pageWidth:1100
          }
      },
      methods:{
        open(order, id,time,isPrint) {
             this.order = order;
            switch (this.order) {
                case INFO:
                this.title = "火化证明详情";
                this.getCREPROOF(id,time,isPrint);
                break;
                case REPRINT:
                    this.title="补打火化证明";
                    this.getCREPROOF(id,time,isPrint);
                break;
                case REPRINTS:
                    this.title="补打联办单";
                    this.joint(id,time,isPrint);
                break;
    
            default:
            }
        },
  
       
         //获取火化证明URL
        getCREPROOF(id,time,isPrint) {
            
            let data = {
                REGID: id,
                REGCREMATIONDATE:null,
                isPrint:isPrint
            };
            apiBase.DoService(
                data,
                apiBase.getApiAdress().Pdf.UpdatePrintCre,
                res => {
                    this.printUrl = res.data.content.PDFNAME;
                    this.$refs.prints.open();
                }
            );
        },
        //打印联办单
        joint(id){
        let data = {
            REGID:id
        };
        apiBase.DoService(
            data, 
            apiBase.getApiAdress().Pdf.PrintJointOffice,
            res => {
            this.printUrl = res.data.content.PDFNAME;
            this.$refs.prints.open();
            });
        },
    },
      components: {
          sweetModal
      },
    created() {},
  };
</script>

